package com.john.waveview;

import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.RectFloat;
import ohos.app.Context;

/**
 * Created by John on 2014/10/15.
 */
class Solid extends Component implements Component.DrawTask {

    private Paint aboveWavePaint;
    private Paint blowWavePaint;

    public Solid(Context context) {
        this(context,null);
    }

    public Solid(Context context, AttrSet attrs) {
        this(context, attrs, null);
    }

    public Solid(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        DirectionalLayout.LayoutConfig params = new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT);
        params.weight = 1;
        setLayoutConfig(params);

        addDrawTask(this);
    }

    public void setAboveWavePaint(Paint aboveWavePaint) {
        this.aboveWavePaint = aboveWavePaint;
    }

    public void setBlowWavePaint(Paint blowWavePaint) {
        this.blowWavePaint = blowWavePaint;
    }

    @Override
    public void onDraw(Component component, Canvas canvas) {
        canvas.drawRect(new RectFloat(getLeft(), 0, getRight(), getBottom() + 100), blowWavePaint);
        canvas.drawRect(new RectFloat(getLeft(), 0, getRight(), getBottom() + 100), aboveWavePaint);
    }
}
